package com.pig4cloud.pigx.knowledge.support.feign;

import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
import com.pig4cloud.pigx.common.core.util.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author lengleng
 * @date 2024/4/15
 */
@FeignClient(contextId = "remoteTableInfoService", value = ServiceNameConstants.CODEGEN_SERVICE)
public interface RemoteTableInfoService {

	/**
	 * 查询全部的数据源名称
	 * @return
	 */
	@GetMapping("/dsconf/list")
	R<Map<String, Object>> listDs();

	/**
	 * 查询表的全部字段
	 * @param dsName 数据源
	 * @param tableName 表名
	 * @return
	 */
	@GetMapping("/table/ddl/{dsName}/{tableName}")
	R<String> listColumn(@PathVariable("dsName") String dsName, @PathVariable("tableName") String tableName);

	/**
	 * 执行 SQL
	 * @param dsName
	 * @param sql SQL格式
	 * @return {@link R }
	 */
	@GetMapping("/ext/execSQL")
	R execSQL(@RequestParam String dsName, @RequestParam String sql);

}
